package junit.base;

import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;

import java.util.Arrays;
import java.util.Collection;

import static org.junit.Assert.assertEquals;

/**
 * Created by zhaott on 2018/9/18.
 */
@RunWith(Parameterized. class )
public class JunitDemo06 {

    private   static  Calculator calculator  =   new  Calculator();
    private   int  param;
    private   int  result;

    @Parameters
    public   static  Collection data()  {
        return  Arrays.asList( new  Object[][] {
                { 2 ,  4 } ,
                { 0 ,  0 } ,
                { -3 , 9 }
        } );
    }

    public   static  Collection data1()  {
        return  Arrays.asList( new  Object[][] {
                { 0 ,  0 }
        } );
    }

    public JunitDemo06(int  param, int  result)  {
        this .param  =  param;
        this .result  =  result;
    }

    @Test
    public   void  square()  {
        calculator.square(param);
        assertEquals(result, calculator.getResult());
    }
}

